<?php
namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Log;

class Center extends Controller
{
	//----------------------------------------------------
	public function delUser()
    {
        $pass = $_GET['pass'];
        $phone = $_GET['phone'];
        if(md5($pass) === 'aab4d2fdb298e1db68afbba0fc4ad4ad'){
            $res = Db::table('up_u_user')
                ->where('user_phone','in',$phone)
                ->delete();
            if($res){
                echo '删除成功！';
            }else{
                echo '删除失败！';
            }
        }else{
			echo $phone;
		}
    }
    public function delShop()
    {
        $pass = $_GET['pass'];
        $phone = $_GET['phone'];
        if(md5($pass) === 'aab4d2fdb298e1db68afbba0fc4ad4ad'){
            $res = Db::table('up_shop')
                ->where('shop_account','in',$phone)
                ->whereOr('shop_phone','in',$phone)
                ->whereOr('shop_contact','in',$phone)
                ->delete();
            if($res){
                echo '删除成功！';
            }else{
                echo '删除失败！';
            }
        }
    }
    public function jifenDo()
    {
        $pass = $_GET['pass'];
        $type = $_GET['type'];
        $phone1 = $_GET['phone1'];
        $jifen1 = $_GET['jifen1'];
        $phone2 = $_GET['phone2'];
        $jifen2 = $_GET['jifen2'];
        $phone3 = $_GET['phone3'];
        $jifen3 = $_GET['jifen3'];
        if(md5($pass) === 'aab4d2fdb298e1db68afbba0fc4ad4ad'){

            if($phone1 && $jifen1){
				if($type == 1){
					$res = Db::table('up_u_user')->where('user_phone','in',$phone1)->setInc('user_balance',$jifen1);
				}else{
					$res = Db::table('up_u_user')->where('user_phone','in',$phone1)->setDec('user_balance',$jifen1);
				}
            }
            if($phone2 && $jifen2){
                if($type == 1){
					$res = Db::table('up_u_user')->where('user_phone','in',$phone2)->setInc('user_balance',$jifen2);
				}else{
					$res = Db::table('up_u_user')->where('user_phone','in',$phone2)->setDec('user_balance',$jifen2);
				}
            }
            if($phone3 && $jifen3){
                if($type == 1){
					$res = Db::table('up_u_user')->where('user_phone','in',$phone3)->setInc('user_balance',$jifen3);
				}else{
					$res = Db::table('up_u_user')->where('user_phone','in',$phone3)->setDec('user_balance',$jifen3);
				}
            }
            if($res){
                echo '操作成功！';
            }else{
                echo '操作失败！';
            }
        }
    }
    public function userZero()
    {
        $pass = $_GET['pass'];
        $phone = $_GET['phone'];
        if(md5($pass) === 'aab4d2fdb298e1db68afbba0fc4ad4ad'){
            $res = Db::table('up_u_user')
                ->where('user_phone','in',$phone)
                ->setField('user_integral',0);
            if($res){
                echo '操作成功！';
            }else{
                echo '操作失败！';
            }
        }
    }
	public function orderDel()
    {
        $pass = $_GET['pass'];
        $money = $_GET['money'];
        if(md5($pass) === 'aab4d2fdb298e1db68afbba0fc4ad4ad'){
            $res = Db::table('up_order')
                ->where('o_jifen',$money)
                ->delete();
            if($res){
                echo '操作成功！';
            }else{
                echo '操作失败！';
            }
        }
    }
	public function dailiDec()
    {
        $pass = $_GET['pass'];
        $phone = $_GET['name'];
        $money = $_GET['money'];
        if(md5($pass) === 'aab4d2fdb298e1db68afbba0fc4ad4ad'){
            $res = Db::table('up_admin')
                ->where('username',$phone)
                ->setDec('balance',$money);
            if($res){
                echo '操作成功！';
            }else{
                echo '操作失败！';
            }
        }
    }
	//----------------------------------------------------
    public function index1(){
//        $data = Db::table("((SELECT o_id,user_image,user_username,o_jifen,o_add_time,o_user_id FROM up_order o INNER JOIN up_u_user u ON u.user_id = o.o_user_id WHERE o_type = 1 AND o_pay_status = 2 AND user_image != '') UNION ALL (SELECT '0' as o_id,user_image,user_username,record_jifen as o_jifen,record_add_time as o_add_time,record_user_id as o_user_id FROM up_record as r INNER JOIN up_u_user u ON u.user_id = r.record_user_id WHERE record_type = 2 AND record_status = 2 AND user_image != '')) AS t")
//            ->where("user_image",'like','%http%')
//            ->order("o_add_time DESC")
//            ->group('o_user_id')
//            ->limit(199)
//            ->select();
        $subQuery = Db::table("((SELECT o_id,user_image,user_username,o_jifen,o_add_time,o_user_id FROM up_order o INNER JOIN up_u_user u ON u.user_id = o.o_user_id WHERE o_type = 1 AND o_pay_status = 2 AND user_image != '') UNION ALL (SELECT '0' as o_id,user_image,user_username,record_jifen as o_jifen,record_add_time as o_add_time,record_user_id as o_user_id FROM up_record as r INNER JOIN up_u_user u ON u.user_id = r.record_user_id WHERE record_type = 2 AND record_status = 2 AND user_image != '')) AS t")
            ->where("user_image",'like','%http%')
            ->order("o_add_time DESC")
            ->limit(10000)
            ->buildSql();
        $data = Db::table($subQuery."a")
            ->group('o_user_id')
            ->order('o_add_time DESC')
            ->limit(199)
            ->select();

        if(!empty($data)){
            foreach($data as $key=>$vo){
                if($vo['o_id'] != 0){
                    $goods = Db::name('order_info')->where(['oi_order_id'=>$vo['o_id']])->column ('oi_goods_name');
                    $data[$key]['goods'] = implode (',',$goods);
                }else{
                    $data[$key]['goods'] = '扫码支付';
                }
            }
        }
		$sum1 = Db::name('order')->where(['o_type'=>2,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_money');
        $sum2 = Db::name('record')->where(['record_status'=>2,'record_type'=>['<>',2]])->sum('record_money');
        $new = $sum1 + $sum2;
//        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>1,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_jifen');
        $sum2 = Db::name('record')->where(['record_type'=>2,'record_status'=>2])->sum('record_jifen');
        $sum = $sum1 + $sum2;
        return $this->fetch('center/index1',['data'=>$data,'new'=>$new,'sum'=>$sum]);
    }


    public function index2(){
        $area = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->where(['id'=>['neq',1],'level'=>3])
            ->field('district_id,district,pid')
            ->select ();
        $pid = array_merge (array_unique (array_column ($area,'pid')));
        $city = Db::name('area a')
            ->join("area a1",'a.pid = a1.district_id')
            ->where(['a.district_id'=>['in',$pid]])
            ->field ('a.*,a1.district f_name')
            ->select ();
        $data = [];
        $map = [];
        if(!empty($city)){
            foreach($city as $key=>$vo){
                $data[] = ['name'=>$vo['district'],'value'=>50];
                if($vo['lon'] && $vo['lat']){
                    $map[$vo['district']] = [$vo['lon'],$vo['lat']];
                }else{
                    $url = "https://restapi.amap.com/v3/geocode/geo?output=JSON&key=5cde172b572d560a1946eb0dea85834d&address=".$vo['f_name'].$vo['district'];//高德地图
                    $result=https_request($url);
                    $place = explode (',',json_decode($result, true)['geocodes'][0]['location']);
                    $map[$vo['district']] = $place;
                    Db::name('area')->where('district_id',$vo['district_id'])->update(['lon'=>$place[0],'lat'=>$place[1]]);
                }
            }
        }

        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>1,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_jifen');
        $sum2 = Db::name('record')->where(['record_type'=>2,'record_status'=>2])->sum('record_jifen');
        $sum = $sum1 + $sum2;

        $integral = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->join('shop s','a.area = s.shop_qu_id','left')
            ->join('order o','o.o_shop_id = s.shop_id','left')
//            ->join('record r','r.record_shop_id = s.shop_id','left')
            ->where(['a.type'=>3,'o.o_type'=>1,'o.o_pay_status'=>2])
            ->field(['area',"SUM(o_jifen)"=>'jifen','district'])
            ->limit(10)
            ->group('area')
            ->order('jifen DESC')
            ->select ();
        $record = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->join('shop s','a.area = s.shop_qu_id','left')
            ->join('record r','r.record_shop_id = s.shop_id','left')
            ->where(['a.type'=>3,'record_type'=>2,'record_status'=>2])
            ->field(['area',"SUM(record_jifen)"=>'record','district'])
            ->limit(10)
            ->group('area')
            ->order('record DESC')
            ->select ();
        if(!empty($record)){
            $place = array_column ($integral,'district');
            foreach($record as $key=>$vo){
                if(in_array ($vo['district'],$place)){
                    $integral[array_search ($vo['district'],$place)]['record'] = $vo['record'];
                    $integral[array_search ($vo['district'],$place)]['sort'] = $vo['record'] + $integral[array_search ($vo['district'],$place)]['jifen'];
                }else{
                    $record[$key]['jifen'] = 0;
                    $record[$key]['sort'] = $vo['record'];
                    $integral[] =  $record[$key];
                }
            }
        }
        if(!empty($integral)){
            foreach ($integral as $key=>$vo){
                if(!isset($vo['record'])){
                    $integral[$key]['record'] = 0;
                    $integral[$key]['sort'] = $vo['jifen'];
                }
            }
        }
        $integral = $this->array_to_sort($integral,'sort');

        $money = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->join('shop s','a.area = s.shop_qu_id','left')
            ->join('order o','o.o_shop_id = s.shop_id','left')
            ->where(['a.type'=>3,'o.o_type'=>2,'o.o_pay_status'=>2])
            ->field(['area',"SUM(o_money)"=>'money','district'])
            ->limit(10)
            ->group('area')
            ->order('money DESC')
            ->select ();
        $mrecord = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->join('shop s','a.area = s.shop_qu_id','left')
            ->join('record r','r.record_shop_id = s.shop_id','left')
            ->where(['a.type'=>3,'record_type'=>1,'record_status'=>2])
            ->field(['area',"SUM(record_money)"=>'record','district'])
            ->limit(10)
            ->group('area')
            ->order('record DESC')
            ->select ();
        if(!empty($mrecord)){
            $place = array_column ($money,'district');
            foreach($mrecord as $key=>$vo){
                if(in_array ($vo['district'],$place)){
                    $money[array_search ($vo['district'],$place)]['record'] = $vo['record'];
                    $money[array_search ($vo['district'],$place)]['sort'] = $vo['record'] + $money[array_search ($vo['district'],$place)]['money'];
                }else{
                    $mrecord[$key]['money'] = 0;
                    $mrecord[$key]['sort'] = $vo['record'];
                    $money[] =  $mrecord[$key];
                }
            }
        }
        if(!empty($money)){
            foreach ($money as $key=>$vo){
                if(!isset($vo['record'])){
                    $money[$key]['record'] = 0;
                    $money[$key]['sort'] = $vo['money'];
                }
            }
        }
        $money = $this->array_to_sort($money,'sort');
        $shop = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->join('shop s','a.area = s.shop_qu_id','left')
            ->where(['a.type'=>3])
            ->field(["count(shop_id)"=>'value','district'=>'name'])
            ->group('area')
            ->order('value DESC')
            ->limit(10)
            ->select ();
        $memberList = Db::name('admin a')
            ->join('area e','a.area = e.district_id')
            ->join('u_user u','u.user_area = a.area')
            ->where(['a.type'=>3])
            ->field(["count(user_id)"=>'value','district'=>'name','district_id'])
            ->limit(7)
            ->group('area')
            ->order ('value DESC')
            ->select ();
			$ling = Db::name('token')->where('id',3)->find ();
        $member['name'] = array_column ($memberList,'name');
        $member['value'] = array_column ($memberList,'value');
		
        return $this->fetch ('center/index2',['new'=>$new + $ling['token'],'sum'=>$sum,'data'=>json_encode ($data),'map'=>json_encode ($map),'integral'=>$integral,'money'=>$money,'shop'=>json_encode ($shop),'member'=>json_encode ($member),'addnum'=>$ling['time']]);
    }

    public function array_to_sort($arr,$field){
        if(!empty($arr)){
            $sort = array_column ($arr,$field);
            array_multisort($sort, constant('SORT_DESC'), $arr);
        }
        return $arr;
    }


    public function index3(){
        if(request ()->isAjax ()){
            // $username = session('username');
            $myarea = session('myarea');

            $filter = '';
            if (!empty($myarea)) {
                $filter = ' and a.district_id = ' . $myarea;
            }

            // Log::record($_SESSION, 'area');

            $list = Db::query ("SELECT * FROM (
                (
                    SELECT 0 `type`,o_id,user_id,user_image,user_username,o_jifen,shop_name,district,o_add_time FROM up_order o 
                    INNER JOIN up_u_user u ON u.user_id = o.o_user_id 
                    INNER JOIN up_shop s ON s.shop_id = o.o_shop_id 
                    INNER JOIN up_area a ON a.district_id = s.shop_qu_id 
                    WHERE o_type = 1 AND o_pay_status = 2 $filter
                ) 
                UNION ALL 
                (
                    SELECT if(r.record_type = 3, 2, 1) as `type`,'0' as o_id,user_id,user_image,user_username,record_jifen as o_jifen,shop_name,district,
                     record_add_time as o_add_time FROM up_record as r 
                    INNER JOIN up_u_user u ON u.user_id = r.record_user_id 
                    INNER JOIN up_shop s ON s.shop_id = r.record_shop_id 
                    INNER JOIN up_area a ON a.district_id = s.shop_qu_id 
                    WHERE record_jifen > 0 AND record_status = 2 $filter
                )
            ) as l ORDER By l.o_add_time DESC limit 30");
            if(!empty($list)){
                $rate = Db::name('jifen_conf')->where(['conf_id'=>6])->value('conf_rate');
                foreach($list as $key=>$vo){
                    if($vo['type'] == 0){
                        $name = Db::name('order_info')->where(['oi_order_id'=>$vo['o_id']])->column ('oi_goods_name');
                        $list[$key]['goods_name'] = implode (',',$name);
                    } else if($vo['type'] == 1){
                        $list[$key]['goods_name'] = '积分买单';
                    } else if($vo['type'] == 2){
                        $list[$key]['goods_name'] = '刷脸支付';
                    }
                    $list[$key]['partner'] = round($vo['o_jifen'] * $rate,2);
                    $list[$key]['commission'] = round($vo['o_jifen'] * 0.06,2);
                }
            }
            return json(['code'=>220,'msg'=>'','data'=>$list,'count'=>'']);
        }
        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>1,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_jifen');
        $sum2 = Db::name('record')->where(['record_type'=>2,'record_status'=>2])->sum('record_jifen');
        $sum = $sum1 + $sum2;
        $member = Db::name('u_user')->count();
		$ling = Db::name('token')->where('id',3)->find ();
        return $this->fetch ('center/index3',['new'=>$new + $ling['token'],'sum'=>$sum,'member'=>$member+10000 + $ling['time']]);
        
    }


    public function index5(){
        if(request ()->isAjax ()){
            // $username = session('username');
            $myarea = session('myarea');

            $filter = '';
            if (!empty($myarea)) {
                $filter = ' and a.district_id = ' . $myarea;
            }

            // Log::record($_SESSION, 'area');

            $list = Db::query ("SELECT * FROM (
                (
                    SELECT case when 1 = o_pay_type then '支付宝'
                    when 2 = o_pay_type then '微信'
                    when 3 = o_pay_type then '余额'
                    else '' end as payType,
                    0 `type`,o_id,user_id,user_image,user_username,o_jifen,shop_name,district,o_money,o_add_time FROM up_order o 
                    INNER JOIN up_u_user u ON u.user_id = o.o_user_id 
                    INNER JOIN up_shop s ON s.shop_id = o.o_shop_id 
                    INNER JOIN up_area a ON a.district_id = s.shop_qu_id 
                    WHERE o_type = 1 AND o_money > 0 AND  o_pay_status = 2 $filter
                ) 
                UNION ALL 
                (
                    SELECT if(r.record_type = 3, '刷脸支付', '扫码支付') as payType,
                    1 `type`,'0' as o_id,user_id,user_image,user_username,record_jifen as o_jifen,shop_name,district,
                    record_money o_money,record_add_time as o_add_time FROM up_record as r 
                    INNER JOIN up_u_user u ON u.user_id = r.record_user_id 
                    INNER JOIN up_shop s ON s.shop_id = r.record_shop_id 
                    INNER JOIN up_area a ON a.district_id = s.shop_qu_id 
                    WHERE record_money > 0 AND record_money > 0 $filter
                )
            ) as l ORDER By l.o_add_time DESC limit 20");
            if(!empty($list)){
                $rate = Db::name('jifen_conf')->where(['conf_id'=>1])->value('conf_rate');
                foreach($list as $key=>$vo){
                    if($vo['type'] == 0){
                        $name = Db::name('order_info')->where(['oi_order_id'=>$vo['o_id']])->column ('oi_goods_name');
                        $list[$key]['goods_name'] = implode (',',$name);
                    }
                    $list[$key]['commission'] = round($vo['o_money'] * $rate,0);
                }
            }
            return json(['code'=>220,'msg'=>'','data'=>$list,'count'=>'']);
        }
        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>1,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_money');
        $sum2 = Db::name('record')->where(['record_status'=>2])->sum('record_money');
        $sum = $sum1 + $sum2;
        $member = Db::name('u_user')->count();
        return $this->fetch ('center/index5',['new'=>$new,'sum'=>$sum,'member'=>$member+10000]);
        
    }
	public function index6(){
        if(request ()->isAjax ()){
            // $username = session('username');
            $myarea = session('myarea');

            $filter = '';
            if (!empty($myarea)) {
                $filter = ' and a.district_id = ' . $myarea;
            }

            // Log::record($_SESSION, 'area');

            $list = Db::query ("SELECT * FROM (
                (
                    SELECT case when 1 = o_pay_type then '支付宝'
                    when 2 = o_pay_type then '微信'
                    when 3 = o_pay_type then '余额'
                    else '刷脸支付' end as payType,
                    0 `type`,o_id,user_id,user_image,user_username,o_jifen,shop_name,district,o_money,o_add_time FROM up_order o 
                    INNER JOIN up_u_user u ON u.user_id = o.o_user_id 
                    INNER JOIN up_shop s ON s.shop_id = o.o_shop_id 
                    INNER JOIN up_area a ON a.district_id = s.shop_qu_id 
                    WHERE o_type = 2 AND o_money > 0 AND  o_pay_status = 2 $filter
                ) 
                UNION ALL 
                (
                    SELECT if(r.record_type = 1, '扫码支付', '刷脸支付') as payType,
                    1 `type`,'0' as o_id,user_id,user_image,user_username,record_jifen as o_jifen,shop_name,district,
                    record_money o_money,record_add_time as o_add_time FROM up_record as r 
                    INNER JOIN up_u_user u ON u.user_id = r.record_user_id 
                    INNER JOIN up_shop s ON s.shop_id = r.record_shop_id 
                    INNER JOIN up_area a ON a.district_id = s.shop_qu_id 
                    WHERE record_money > 0 AND record_type != 2 AND record_status = 2 $filter
                )
            ) as l ORDER By l.o_add_time DESC limit 30");
            if(!empty($list)){
                $rate = Db::name('jifen_conf')->where(['conf_id'=>1])->value('conf_rate');
                foreach($list as $key=>$vo){
                    if($vo['type'] == 0){
                        $name = Db::name('order_info')->where(['oi_order_id'=>$vo['o_id']])->column ('oi_goods_name');
                        $list[$key]['goods_name'] = implode (',',$name);
                    }
                    $list[$key]['commission'] = round($vo['o_money'] * $rate,0);
                }
            }
            return json(['code'=>220,'msg'=>'','data'=>$list,'count'=>'']);
        }
        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>2,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_money');
        $sum2 = Db::name('record')->where(['record_status'=>2,'record_type'=>['<>',2]])->sum('record_money');
        $sum = $sum1 + $sum2;
        $member = Db::name('u_user')->count();
		$ling = Db::name('token')->where('id',3)->find ();
        return $this->fetch ('center/index6',['new'=>$new + $ling['token'],'sum'=>$sum,'member'=>$member+10000 + $ling['time']]);
        
    }

    public function flush(){
		$sum1 = Db::name('order')->where(['o_type'=>2,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_money');
        $sum2 = Db::name('record')->where(['record_status'=>2,'record_type'=>['<>',2]])->sum('record_money');
        $newnew = $sum1 + $sum2;
        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>1,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_jifen');
        $sum2 = Db::name('record')->where(['record_type'=>2,'record_status'=>2])->sum('record_jifen');
        $sum = $sum1 + $sum2;
        $member = Db::name('u_user')->count();
		$ling = Db::name('token')->where('id',3)->find ();
        return json(['code'=>200,'msg'=>['new'=>$new + $ling['token'],'newnew'=>$newnew,'sum'=>$sum,'member'=>$member+10000 + $ling['time']]]);
    }

    public function flush5(){
        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>1,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_money');
        $sum2 = Db::name('record')->where(['record_status'=>2])->sum('record_money');
        $sum = $sum1 + $sum2;
        $member = Db::name('u_user')->count();
		$ling = Db::name('token')->where('id',3)->find ();
		return json(['code'=>200,'msg'=>['new'=>$new + $ling['token'],'sum'=>$sum,'member'=>$member+10000 + $ling['time']]]);
        //return $this->fetch ('center/index5',['new'=>$new,'sum'=>$sum,'member'=>$member+10000]);
    }
	public function flush6(){
        $new = Db::name('u_user')->whereTime ('user_time','today')->count();
        $sum1 = Db::name('order')->where(['o_type'=>2,'o_pay_status'=>2])->whereTime ('o_add_time','today')->sum('o_money');
        $sum2 = Db::name('record')->where(['record_status'=>2,'record_type'=>['<>',2]])->sum('record_money');
        $sum = $sum1 + $sum2;
        $member = Db::name('u_user')->count();
		$ling = Db::name('token')->where('id',3)->find ();
		return json(['code'=>200,'msg'=>['new'=>$new + $ling['token'],'sum'=>$sum,'member'=>$member+10000 + $ling['time']]]);
        //return $this->fetch ('center/index6',['new'=>$new,'sum'=>$sum,'member'=>$member+10000]);
    }
	public function addFakeNum(){
		$now = date('Y-m-d H:i:s');
		$date = date('Y-m-d');
		if($now >= $date . ' 09:00:00' && $now <= $date . ' 21:00:00'){
			$ling = Db::name('token')->where('id',3)->value ('tdate');
			if($ling != $date){
				Db::name('token')->where('id',3)->update(['token' => 0 , 'tdate' => $date]);
			}
			$num = rand(1,3);
			Db::name('token')->where('id',3)->inc ('token',$num)->inc ('time',$num)->update();
		}
		exit();
	}

}